import { basicRouter } from "@/config/router.config.js";
const configs = require("@/config/config");
import Vue from "vue";
import Router from "vue-router";
// import store from '../store/specification.js'
// import * as path from "path";

Vue.use(Router);

const createRouter = () =>
  new Router({
    mode: "history",
    base:
      process.env.NODE_ENV === "production" ? configs.setting.buildPath : "/",
    routes: basicRouter
  });
const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher;
}

export default router;

//解决vue路由重复导航错误
//获取原型对象上的push函数
const originalPush = Router.prototype.push;
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};
//
// export const createRouter = routes =>
//   new Router({
//     mode: "history",
//     base: process.env.BASE_URL,
//     routes
//   });
